package com.example.ailiyuncloud.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.ailiyuncloud.dto.CommoditySpuDTO;
import com.example.ailiyuncloud.pojo.Result;
import com.example.ailiyuncloud.service.CommoditySpuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: lqj
 * @Date: 2024/05/26/20:30
 * @Description:
 */
@RestController
@RequestMapping("/spu")
public class CommoditySpuController {

    @Autowired
    private CommoditySpuService commoditySpuService;

    @PostMapping("/add")
    public Result<?> addCommoditySpuController(@RequestBody List<CommoditySpuDTO> commoditySpuDTOList) {
        return commoditySpuService.addCommoditySpuService(commoditySpuDTOList);
    }


    @PostMapping("/query")
    public Result<?> queryCommoditySpuController(@RequestParam(defaultValue = "1") int current,
                                                 @RequestParam(defaultValue = "10") int pageSize,
                                                 @RequestBody CommoditySpuDTO commoditySpuDTOList) {
        Page page = new Page(current, pageSize);
        return commoditySpuService.queryCommoditySpuService(page, commoditySpuDTOList);
    }
}
